package Gui;

import java.awt.Color;
import java.awt.Component;
import java.awt.event.ActionEvent;

import javax.swing.text.StyledEditorKit;

public class FontActions {
	
	private Component sendFocus;
	
	public FontActions(Component giveFocusAfter){
		setSendFocus(giveFocusAfter);		
	}

	public Component getSendFocus() {
		return sendFocus;
	}

	public void setSendFocus(Component sendFocus) {
		this.sendFocus = sendFocus;
	}
	
	//innerclasses
	public class MyBoldAction extends StyledEditorKit.BoldAction{		
		@Override
		public void actionPerformed(ActionEvent arg0) {
			super.actionPerformed(arg0);
			//give focus to Textpane
			if(getSendFocus()!=null) getSendFocus().requestFocus();
		}
	}
	
	public class MyForegroundAction extends StyledEditorKit.ForegroundAction{

		
		public MyForegroundAction(String arg0, Color arg1) {
			super(arg0, arg1);
		}
		
		@Override
		public void actionPerformed(ActionEvent arg0) {
			super.actionPerformed(arg0);
			//give focus to Textpane
			if(getSendFocus()!=null) getSendFocus().requestFocus();
		}

	}
	
	public class MyItalicAction extends StyledEditorKit.ItalicAction{
		
		@Override
		public void actionPerformed(ActionEvent arg0) {
			super.actionPerformed(arg0);
			//give focus to Textpane
			if(getSendFocus()!=null) getSendFocus().requestFocus();
		}

	}
	
	public class MyUnderlineAction extends StyledEditorKit.UnderlineAction{
		
		@Override
		public void actionPerformed(ActionEvent arg0) {
			super.actionPerformed(arg0);
			//give focus to Textpane
			if(getSendFocus()!=null) getSendFocus().requestFocus();
		}

	}
	
	public class MyFontFamilyAction extends StyledEditorKit.FontFamilyAction{

		
		public MyFontFamilyAction(String arg0, String arg1) {
			super(arg0, arg1);
		}
		
		@Override
		public void actionPerformed(ActionEvent arg0) {
			super.actionPerformed(arg0);
			//give focus to Textpane
			if(getSendFocus()!=null) getSendFocus().requestFocus();
		}

	}
	
	public class MyFontSizeAction extends StyledEditorKit.FontSizeAction{

		
		public MyFontSizeAction(String arg0, int arg1) {
			super(arg0, arg1);
		}
		
		@Override
		public void actionPerformed(ActionEvent e) {
			super.actionPerformed(e);
			//give focus to Textpane
			if(getSendFocus()!=null) getSendFocus().requestFocus();
		}

	}
	
	

}
